﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FTBS.Models.DAO;
using FTBS.Models.Entities;

namespace FTBS.Models.BLO
{
    public class CommentBLO
    {
        CommentDAO _commentDao = new CommentDAO();

        /// <summary>
        /// load comments of film
        /// </summary>
        /// <param name="filmId"></param>
        /// <returns>list comments</returns>
        /// <author>hungph</author>
        public List<Comment> LoadCommentByFilm(int filmId)
        {
            var listComments = _commentDao.LoadComments(filmId);
            return listComments;
        }

        /// <summary>
        /// get comment
        /// </summary>
        /// <param name="id"></param>
        /// <returns>comment</returns>
        /// <author>hungph</author>
        public Comment LoadComment(int id)
        {
            var comment = _commentDao.LoadCommentById(id);
            return comment;
        }

        /// <summary>
        /// write a comment
        /// </summary>
        /// <param name="comment"></param>
        /// <returns>true: write comment successful; false: write comment fail</returns>
        /// <author>hungph</author>
        public bool WriteComment(Comment comment)
        {
            var result = _commentDao.Add(comment);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Edit a comment
        /// </summary>
        /// <param name="comment"></param>
        /// <returns>true: edit comment successful; false: edit comment fail</returns>
        /// <author>hungph</author>
        public bool EditComment(Comment comment)
        {
            var result = _commentDao.Edit(comment);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// delete a comment
        /// </summary>
        /// <param name="comment"></param>
        /// <returns>true: delete comment successful; false: delete comment fail</returns>
        /// <author>hungph</author>
        public bool DeleteComment(Comment comment)
        {
            var result = _commentDao.Delete(comment);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}